package com.yc.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yc.bean.OrderDetailBean;
import com.yc.mapper.OrderDetailMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zwei
 * @create 2024-10-08 16:09
 */
@Service
public class OrderDetailBizImpl implements OrderDetailBiz{
    private OrderDetailMapper orderDetailMapper;
    @Autowired
    public void setOrderDetailMapper(OrderDetailMapper orderDetailMapper) {
        this.orderDetailMapper = orderDetailMapper;
    }
    @Override
    public List<OrderDetailBean> find() {
        QueryWrapper<OrderDetailBean> qw = new QueryWrapper<>();
        qw.eq("disabled",0);
        return orderDetailMapper.selectList(qw);
    }

    @Override
    public Boolean setOrderDetail(int orderid, int foodid, int buyNum, double discountprice) {
        OrderDetailBean orderDetailBean = new OrderDetailBean();
        orderDetailBean.setOrderid(orderid);
        orderDetailBean.setFoodid(foodid);
        orderDetailBean.setBuynum(buyNum);
        orderDetailBean.setDiscountprice(discountprice);
        return orderDetailMapper.insert(orderDetailBean)>0;
    }
}
